/*
 * @Author: earl 
 * @Date: 2018-12-13 12:18:39 
 * @Last Modified by: earl
 * @Last Modified time: 2018-12-15 14:53:02
 * @Describe:  koa-views 模板中间件
 */

const Koa = require('koa')
const views = require('koa-views')
const path = require('path')
const app = new Koa()

// 加载模板引擎
app.use(views(path.join(__dirname, '../view'), { // 文件路径
  extension: 'ejs' // 后缀名
}))

app.use( async ( ctx ) => {
  let title = 'hello koa2'
  let content = '我是内容'
  await ctx.render('index', { // ejs文件名
    title,content
  })
})

app.listen(3000)

